package jjoms.model.member;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import jjoms.model.item.MessageVO;

import org.springframework.stereotype.Service;

@Service
public class MemberServiceImpl implements MemberService {
	@Resource(name = "memberDAOImpl")
	private MemberDAO memberDAO;

	//회원 등급도 지정해줘야
	public MemberVO login(MemberVO vo) {
		MemberVO mvo = null;
		
		mvo = memberDAO.login(vo);
		/*//회원 등급 조정
		String grade = memberDAO.getGrade(mvo.getMemberId());*/
		
		return mvo;
	}

	public int idcheck(String memberId) {
		return memberDAO.idcheck(memberId);
	}

	public void registerMember(MemberVO vo) {
		memberDAO.registerMember(vo);
	}

	public MemberVO findMemberById(String memberId) {
		return memberDAO.findMemberById(memberId);
	}

	public void updateMember(MemberVO vo) {
		memberDAO.updateMember(vo);
	}

	public List<MemberVO> getAllMemberList() {
		return memberDAO.getAllMemberList();
	}

	public void deleteMember(String memberId) {
		memberDAO.deleteMember(memberId);
	}

	public String findId(String memberName, String phone) {
		return memberDAO.findId(memberName, phone);
	}

	public MemberVO findPassword(String memberId) {
		return memberDAO.findPassword(memberId);
	}

	public int moneyWithTax(int memberMoney) {
		int count = 0;
		count = (int) (memberMoney * 1.2);
		return count;
	}

	public void updateMemberMoney(String memberId, int result1) {
		HashMap map = new HashMap();
		map.put("memberId", memberId);
		map.put("result1", result1);
		memberDAO.updateMemberMoney(map);
	}

	@Override
	public List<String> getAllManagerList() {
		return memberDAO.getAllManagerList();
	}

	@Override
	public void updateSellAuthority(String memberId) {
		memberDAO.updateSellAuthority(memberId);
	}

	@Override
	public void passAuthorityMember(String memberId) {
		memberDAO.passAuthorityMember(memberId);
	}

	@Override
	public List<MessageVO> getMessageBySender(String memberId) {
		return memberDAO.getMessageBySender(memberId);
	}

	@Override
	public List<MessageVO> getMessageByReceiver(String memberId) {
		return memberDAO.getMessageByReceiver(memberId);
	}
	
	@Override
	public void deleteSender(int messageNo){
		memberDAO.updateSenderCheck(messageNo);
		memberDAO.deleteSenderReceiverCheck(messageNo);
	}
	@Override
	public void deleteReceiver(int messageNo){
		memberDAO.updateReceiverCheck(messageNo);
		memberDAO.deleteSenderReceiverCheck(messageNo);
	}

}
